home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 54.zip / BS part 54 / PI IMAGE3_d2.adf / PIToolkit / Source / ExampleMod.c < prev   
Encoding:
C/C++ Source or Header  |  1992-07-11  |  2.8 KB  |  121 lines

  1. /************************************************************************
  2. **********                                                     **********
  3. **********                 PI Extern Module                    **********
  4. **********                    ----------                       **********
  5. **********                                                     **********
  6. **********        Copyright (C) Menti Possibili, snc 1992      **********
  7. **********       Via Di Vittorio, 56 - 50015 Grassina (FI)     **********
  8. **********                   Italy                             **********
  9. **********              All Rights Reserved.                   **********
  10. **********                                                     **********
  11. *************************************************************************
  12. ***
  13. ***  MODULE:
  14. ***
  15. ***    ExampleModule.c
  16. ***
  17. ***  PURPOSE:
  18. ***
  19. ***    Show example of simple PI Fx Module
  20. ***
  21. ***  HISTORY:
  22. ***
  23. ***    1.00 Andrea Focardi    First Release.
  24. ***
  25. ***  NOTE:
  26. ***    
  27. ***    You can copy, modify and distribute without any restriction.
  28. ***
  29. ************************************************************************/
  30.  
  31. #include <exec/types.h>
  32. #include <graphics/gfxbase.h>
  33. #include <intuition/intuitionbase.h>
  34. #include <proto/all.h>
  35. #include <stdio.h>
  36. #include <string.h>
  37.  
  38. #include <paramPI.h>
  39.  
  40. struct IntuitionBase       *IntuitionBase = NULL ;
  41. struct GfxBase        *GfxBase = NULL ;
  42.  
  43. struct Window         *w, *tbw;
  44. struct RastPort        *mainrp, *tbrp, *targetrp;
  45.  
  46. struct Parameters_PI    *pi;
  47.  
  48.  
  49. void make(void)
  50. {
  51.     Move(mainrp,100,100); Text(mainrp,"Hello, World!",13);
  52. }
  53.  
  54.  
  55. void ExitPI(
  56.     char     *errore,
  57.     int     ret)
  58. {
  59.     printf(errore);
  60.  
  61.     if ( ret )
  62.         Delay(50);
  63.  
  64.     if ( GfxBase )
  65.         CloseLibrary( (struct Library *) GfxBase);
  66.  
  67.     if ( IntuitionBase )
  68.         CloseLibrary( (struct Library *) IntuitionBase);
  69.  
  70.     exit(ret);
  71. }
  72.  
  73. main(int argc,char *argv[])
  74. {   
  75.     printf("\nPI Image Example Fx Module.\n");
  76.  
  77.     if ( argc != 2 )
  78.         ExitPI("\nError: wrong parameters.\n",RETURN_ERROR);
  79.  
  80.     if ( FindPort("MPA") == NULL )
  81.         ExitPI("\nError: PI Image not run.\n",RETURN_ERROR);
  82.  
  83.     pi = (struct Parameters_PI *) atol(argv[1]);
  84.     
  85.     if ( pi->magic != MOD_MAGIC )
  86.         ExitPI("\nError: incorrect struct.\n",RETURN_FAIL);
  87.  
  88.     if ( IntuitionBase = ( struct IntuitionBase * ) OpenLibrary ("intuition.library",0) )
  89.         {
  90.         if ( GfxBase = ( struct GfxBase * ) OpenLibrary ("graphics.library",0) )
  91.             {
  92.  
  93.             /* get ptr */
  94.     
  95.             w          = pi->mainwindow ;
  96.             tbw        = pi->tbwindow ;
  97.             mainrp    = w->RPort ;
  98.             tbrp         = tbw->RPort ;
  99.             targetrp    = pi->targetrp ;
  100.                 
  101.             /* application starts */
  102.  
  103.  
  104.             /* write only "Hello, World!" and then exit */
  105.  
  106.             make();
  107.     
  108.             /* application ends */            
  109.  
  110.             }
  111.         else
  112.             ExitPI("\nError: can't open graphics.library.\n",RETURN_FAIL);
  113.  
  114.         }
  115.     else
  116.         ExitPI("\nError: can't open intuition.library.\n",RETURN_FAIL);
  117.     
  118.     ExitPI("",RETURN_OK);
  119. }
  120.  
  121.